{include file='header'/}
<body>
<div class="weadmin-body">
    <form class="layui-form" action="javascript:;" onsubmit="return dosub(this)">
        <div class="layui-form-item">
            <label for="username" class="layui-form-label">
                <span class="we-red">*</span>所属组别
            </label>
            <div class="layui-input-inline block" style="width:435px;">
                <div id="wordTags"></div>
                <input type="hidden" id="groups" name="group" autocomplete="off" class="layui-input readonly-bg" readonly>
                <input type="text" id="groups_name" name="groups_name" lay-verify="required" class="layui-input readonly-bg" readonly>
            </div>
            <div class="layui-input-inline">
                <a class="layui-btn layui-btn-lvse" onclick="WeAdminShow('选择组别','{:url('public_change_auth_group')}','800')">点击选择组别</a>
            </div>
        </div>
        <div class="layui-form-item">
            <label for="username" class="layui-form-label">
                <span class="we-red">*</span>登录名
            </label>
            <div class="layui-input-block">
                <input type="text" id="username" name="username" lay-verify="required" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="password" class="layui-form-label">
                <span class="we-red">*</span>密码
            </label>
            <div class="layui-input-block">
                <input type="password" id="password" name="password" lay-verify="newPwd|required" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="password2" class="layui-form-label">
                <span class="we-red">*</span>确认密码
            </label>
            <div class="layui-input-block">
                <input type="password" id="password2" name="password2" lay-verify="regpwd|required" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label for="nickname" class="layui-form-label">昵称</label>
            <div class="layui-input-block">
                <input type="text" id="nickname" name="nickname" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="email" class="layui-form-label"><span class="we-red">*</span>邮箱</label>
            <div class="layui-input-block">
                <input type="text" id="email" name="email" autocomplete="off" class="layui-input" lay-verify="email">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="status" class="layui-form-label">是否启用</label>
            <div class="layui-input-block" id="status">
                <input type="radio" name="status" value="normal" title="启用" checked>
                <input type="radio" name="status" value="hidden" title="禁用">
            </div>
        </div>
        <input type="hidden" name="dosubmit" value="1">
        <div class="layui-form-item">
            <label class="layui-form-label"></label>
            <button class="layui-btn"  lay-submit="" >确定</button>
        </div>
    </form>
</div>
{include file='footer'/}
<script>
    layui.use(['form','upload', 'layer','element'], function(){
        var form = layui.form
            ,element = layui.element;
        /*通用简单的表单验证*/
        form.verify({
            newPwd: [
                /^[\S]{6,12}$/
                ,'密码必须6到12位，且不能出现空格'
            ],
            regpwd:function (value) {
                if($("#password").val()!=value){
                    return "两次输入密码不一致，请重新输入！";
                }
            }
        });
    });
    function dosub(obj) {
        var groups_name = $("#groups_name").val();
        if(groups_name ==''){
            layer.msg('组别不能为空');
            return false;
        }
        $.ajax({
            type: 'POST',
            url: '{:url('admin_add')}',
            data: $(obj).serialize(),
            dataType: "json",
            success: function (res) {
                if(res.status == 1){
                    layer.msg(res.msg, {
                        icon: 1,
                        time: 200
                    }, function(){
                        parent.location.reload();
                    });
                }else{
                    layer.msg(res.msg);
                }
            }
        });
        return false;
    }
</script>
</body>
</html>